<include file="public@header"/>
<style>
    .controls {
        color: #999
    }

    .minwidth {
        width: 55px !important
    }

    div[name='d_gaiban'], div[name='d_al'] {
        width: 100%;
        float: left;
    }

    .form-horizontal .control-group1 {
    }

    .inputw {
        width: 80px !important;
    }

    .marleft {
        margin-left: 90px !important;
    }
    .a {
        /*display: inline-block;*/
        display: none;
    }
</style>
</head>
<body>

<php>$type=''</php>
<div class="wrap">
    <ul class="nav nav-tabs">
        <li><a href="{:url('Rock/product')}">石材产品库</a></li>
        <li><a href="{:url('Rock/producttypeadd')}">新增石材产品</a></li>
        <li class="active"><a href="{:url('Rock/productys')}">新增艺术墓</a></li>
    </ul>
    <form method="post" class="form-horizontal js-ajax-form" action="{:url('Rock/productysadd_post')}"
          style="width:100%; float:left">
        <fieldset>
            <input type="hidden" name="pro_type" value="2">
            <input type="hidden" name="itype[]" value="5">
            <input type="hidden" name="product_id">
            <div class="p_title">
                <span class="span_title">基础信息</span>
            </div>
            <div class="control-group1-p">
                <div class="control-group1" style="width:100%">
                    <label class="control-label">状态:</label>
                    <div class="controls">
                        <select class="form-control" name="pro_status" style="width: 250px">
                            <option value="1">启用</option>
                            <option value="2">停用</option>
                        </select>
                    </div>


					</div>
					<div class="control-group1" style="width:100%">
						<label class="control-label">方案编号:</label>
						<div class="controls">
							<input type="text" class="form-control" name="pro_name" required value="" style="width: 250px">
						</div>
					</div>

				</div>

            <div class="p_title">
                <span class="span_title">墓碑信息</span>
            </div>

            <div class="control-group1-p">

                <div class="control-group1" style="width:100%;margin-left: 6%">
                    <label>上传签章方案：</label>
                    <input type="hidden" name="upload_plan" id="thumb" >
                    <a href="javascript:uploadOne('上传签章方案', '#thumb');">
                        <h5 class="btn btn-primary">上传</h5>
                    </a>
                    <h5 class="a" style="color: #449D44">上传成功</h5>
                </div>

                <div class="control-group1" style="width:100%;margin-left: 5.6%">
                    <input type="hidden" name="pro_id[]" id="pro_id1">
                    <label>【<input type="text" name="mb_name[]" value="定制墓碑1" id="mb_name_1" class="mb_name_1" style="width: 70px;border: 0">】</label>
                    <label style="margin-left: 15px">位置：
                        <input type="text" name="address[]" style="width: 150px;" class="form-control" required>
                    </label>
                    <div class="btn btn-primary" style="margin-left: 30px">
                        <a id="add_mub1">
                            <span style="color: #fff">添加详细墓碑信息</span>
                        </a>
                    </div>
                </div>

                <div class="control-group1" style="width:100%;margin-left: 5.6%">
                    <input type="hidden" name="pro_id[]" id="pro_id2" >
                    <label>【<input type="text" name="mb_name[]" value="定制墓碑2" id="mb_name_2" class="mb_name_2" style="width: 70px;border: 0">】</label>
                    <label style="margin-left: 15px">位置：
                        <input type="text" name="address[]" style="width: 150px;" class="form-control" required>
                    </label>
                    <div class="btn btn-primary" style="margin-left: 30px">
                        <a id="add_mub2" name="other">
                            <span style="color: #fff">添加详细墓碑信息</span>
                        </a>
                    </div>
                </div>

                <div class="control-group1" style="width:100%;margin-left: 5.6%">
                    <input type="hidden" name="pro_id[]" id="pro_id3" >
                    <label>【<input type="text" name="mb_name[]" value="定制墓碑3" id="mb_name_3" class="mb_name_3" style="width: 70px;border: 0">】</label>
                    <label style="margin-left: 15px">位置：
                        <input type="text" name="address[]" style="width: 150px;" class="form-control" required>
                    </label>
                    <div class="btn btn-primary" style="margin-left: 30px">
                        <a id="add_mub3">
                            <span style="color: #fff">添加详细墓碑信息</span>
                        </a>
                    </div>
                </div>

                <div class="control-group1" style="width:100%;margin-left: 6%">
                    <div class="btn btn-primary" id="add_gaiban">添加其他材料</div>
                </div>
            </div>
        </fieldset>
        <div class="form-actions">
            <button type="submit" class="btn btn-primary js-ajax-submit">{:lang('ADD')}</button>
            <a class="btn btn-default" href="javascript:history.back(-1);">{:lang('BACK')}</a>
        </div>
    </form>

</div>
<script type="text/javascript" src="__STATIC__/js/admin.js?v={:time()}"></script>
<script type="text/javascript" src="__STATIC__/js/layer/layer.js"></script>
<script>


    // 墓碑详情1
    $("#add_mub1").click(function(){
        var url = "{:url('Admin/Rock/productysmb')}?type=1";
        layer.open({
            type: 2,     //包括但不限于一个值 ，具体 可以去查看  2  就是URL
            title: '添加墓碑详情',
            maxmin: true,
            shadeClose: true,       //我觉着应该再加个onclick shade 遮罩层  Close  关闭
            shade: 0.6,             //遮罩层 透明度
            area: ['95%', '75%'],
            content: url,            //这个和type  有关系，比如type = 1   content='这里可以直接写'

        });
    });

    // 墓碑详情2
    $("#add_mub2").click(function(){
        var url = "{:url('Admin/Rock/productysmb')}?type=2";
        layer.open({
            type: 2,     //包括但不限于一个值 ，具体 可以去查看  2  就是URL
            title: '添加墓碑详情',
            maxmin: true,
            shadeClose: true,       //我觉着应该再加个onclick shade 遮罩层  Close  关闭
            shade: 0.6,             //遮罩层 透明度
            area: ['95%', '95%'],   //大小
            content: url,            //这个和type  有关系，比如type = 1   content='这里可以直接写'
        });
    });
    // 墓碑详情3
    $("#add_mub3").click(function(){
        var url = "{:url('Admin/Rock/productysmb')}?type=3";
        layer.open({
            type: 2,     //包括但不限于一个值 ，具体 可以去查看  2  就是URL
            title: '添加墓碑详情',
            maxmin: true,
            shadeClose: true,       //我觉着应该再加个onclick shade 遮罩层  Close  关闭
            shade: 0.6,             //遮罩层 透明度
            area: ['95%', '95%'],   //大小
            content: url,            //这个和type  有关系，比如type = 1   content='这里可以直接写'
        });
    });

    $(document).ready(function () {
        var catejson = {$cateJson};
        var catehtml = "";
        $.each(catejson, function (i, n) {
            catehtml += "<option value='" + n.id + "'>" + n.name + "</option>";
        });

        $(document).on('click', '#del_gaiban', function () {
            $(this).parents("div[name='base']").remove();
        });
        $("#add_gaiban").click(function () {
            var str = "";
            str = "<div name='base'><div class='control-group1' style='width: 24%'>" +
                "<input type='hidden' name='isort[]' value='1' >" +
                "<div class='controls' style='margin-left: 80px'>" +
                "<input type='text' class='form-control ' name='iname[]' style='width:100px;' value=''>：" +
                "<input type='text' name='iwidth[]' placeholder='宽' class='minwidth form-control'  value='' style='margin-right:5px'>" +
                "<input type='text' name='iheight[]' placeholder='高' class='minwidth form-control' value='' style='margin-right:5px'>" +
                "<input type='text' name='ithick[]' placeholder='厚' class='minwidth form-control' value='' > mm" +
                "</div>" +
                "</div>" +
                "<div class='control-group1' style='width: 19%'>" +
                "<label class='control-label'>材料种类:</label>" +
                "<div class='controls'>" +
                "<select class='form-control' name='icate[]'>";
            str += catehtml;
            str += "</select>" +
                "</div>" +
                "</div>" +
                "<div class='control-group1' style='width:12%'>" +
                "<label class='control-label inputw'>数量:</label>" +
                "<div class='controls marleft'>" +
                "<input type='text' class='form-control' name='inumber[]' style='width:100px;' value='1'>" +
                "</div>" +
                "</div>" +
                "<div class='control-group1' style='width:12%'>" +
                "<label class='control-label inputw'>材料价格:</label>" +
                "<div class='controls marleft'>" +
                "<input type='text' class='form-control' name='imaterial_price[]' style='width:100px;' value=''>" +
                "</div>" +
                "</div>" +
                "<div class='control-group1' style='width:12%' >" +
                "<label class='control-label inputw'>维修单价:</label>" +
                "<div class='controls marleft'>" +
                " <input type='text' class='form-control' name='irepair_price[]' style='width:100px;' value=''>" +
                "</div>" +
                "</div>" +
                "<div class='control-group1'  style='width:12%'>" +
                "<label class='control-label inputw'>更换单价:</label>" +
                "<div class='controls marleft'>" +
                "<input type='text' class='form-control' name='ichange_price[]' style='width:100px;' value=''>" +
                "</div>" +
                "</div>" +
                "<div class='control-group' style='width:2%;float:left;'>" +
                "<div class='btn btn-primary' id='del_gaiban'>-</div>" +
                "</div></div>";

            $(this).parent("div").after(str);
        })
        // 主要
        $(document).on('blur', "input[name='imaterial_price[]']", function () {
            var width = $(this).closest("div[name='base']").find("input[name='iwidth[]']").val();
            var height = $(this).closest("div[name='base']").find("input[name='iheight[]']").val();
            var thick = $(this).closest("div[name='base']").find("input[name='ithick[]']").val();
            var material_price = $(this).closest("div[name='base']").find("input[name='imaterial_price[]']").val();
            var change_price = 0;
            if (width != '' && height != '' && thick != '' && material_price != '') {
                change_price = width * height * thick * material_price;
                change_price = change_price.toFixed(2);
            }
            $(this).closest("div[name='base']").find("input[name='ichange_price[]']").val(change_price);
        });
        // // 墓碑详情1
        // $("#add_mub1").click(function () {
        //     var name = $(this).parents("div[class='control-group1']").find("input[name='name1']").val();
        //     var url = '{:url("Admin/Rock/productysmb")}?beiname=' + name;
        //     $(this).attr("href", url);
        // })
        // // 墓碑详情2
        // $("#add_mub2").click(function () {
        //     var name = $(this).parents("div[class='control-group1']").find("input[name='name2']").val();
        //     var url = '{:url("Admin/Rock/productysmb")}?beiname=' + name;
        //     $(this).attr("href", url);
        // })
        // 墓碑详情3
        // $("#add_mub3").click(function () {
        //     var name = $(this).parents("div[class='control-group1']").find("input[name='name3']").val();
        //     var url = '{:url("Admin/Rock/productysmb")}?beiname=' + name;
        //     $(this).attr("href", url);
        // })
    })

</script>
